package com.homegoods.discover;

import com.homegoods.area.model.SubModelList;
import com.homegoods.classify.model.Constant;
import com.network.retrofit_rx.Api.ActionSubscriber;
import com.network.retrofit_rx.Api.CommandImpl;
import com.network.retrofit_rx.Api.HttpManager;


import io.reactivex.functions.Consumer;

public class DiscoverApiUtils {
    /**
     * 获取发现里的视频列表
     *
     * @param
     * @param
     * @param consumer AppType=Videolist_   //方法名   固定不变
     *                 outdata=jsonlist     //数据输出方式
     */
    public static void getDiscoverList(Consumer<SubModelList> consumer, Consumer<Throwable> error) {
        CommandImpl command = new CommandImpl.Builder()
                .setUrl(Constant.SERVER_URL + Constant.GET_FIND_VIDEOLIST)
                .addParams("AppType", "Videolist_")
                .addParams("outdata", "jsonlist")
                .setObject(true)
                .setClass(SubModelList.class)
                .create();
        HttpManager.getInstance().get(command, new ActionSubscriber<>(consumer, error, null));
    }

    /**
     * 获取发现里的精选 轮播广告
     *
     * @param
     * @param
     * @param consumer AppType=NewsList_Byid_Bytype  //Byid后面接新闻的记录ID，Bytype后面接0获取新闻的轮播发现列表，Bytype后面接1获取所有的新闻发现列表，Bytype后面接2，同时Byid后面接新闻的记录ID；就是获取新闻的详情
     */
    public static void getDiscoverNewsAdPage(Consumer<SubModelList> consumer, Consumer<Throwable> error) {
        CommandImpl command = new CommandImpl.Builder()
                .setUrl(Constant.SERVER_URL + Constant.GET_FIND_VIDEOLIST)
                .addParams("AppType", "NewsList_Byid_Bytype0")
                .addParams("outdata", "jsonlist")
                .setObject(true)
                .setClass(SubModelList.class)
                .create();
        HttpManager.getInstance().get(command, new ActionSubscriber<>(consumer, error, null));
    }

    /**
     * 获获取发现里的精选 新闻列表
     *
     * @param
     * @param
     * @param consumer AppType=NewsList_Byid_Bytype  //Byid后面接新闻的记录ID，Bytype后面接0获取新闻的轮播发现列表，Bytype后面接1获取所有的新闻发现列表，Bytype后面接2，同时Byid后面接新闻的记录ID；就是获取新闻的详情
     */
    public static void getDiscoverNewsList(Consumer<SubModelList> consumer, Consumer<Throwable> error) {
        CommandImpl command = new CommandImpl.Builder()
                .setUrl(Constant.SERVER_URL + Constant.GET_FIND_VIDEOLIST)
                .addParams("AppType", "NewsList_Byid_Bytype1")
                .addParams("outdata", "jsonlist")
                .setObject(true)
                .setClass(SubModelList.class)
                .create();
        HttpManager.getInstance().get(command, new ActionSubscriber<>(consumer, error, null));
    }

}
